package com.ms.p2p.template.directive;

import com.alibaba.dubbo.config.annotation.Reference;
import com.ms.p2p.entity.content.ArticleCategory;
import com.ms.p2p.provider.ArticleCategoryProvider;
import freemarker.core.Environment;
import freemarker.template.TemplateDirectiveBody;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;
import org.springframework.stereotype.Repository;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * Created by xing_ on 2017/5/21.
 */
@Repository
public class ArticleTypeDirective extends BaseDirective {

    @Reference
    private ArticleCategoryProvider articleCategoryProvider;


    @Override
    public void execute(Environment env, Map params, TemplateModel[] templateModels,
                        TemplateDirectiveBody body) throws TemplateException, IOException {

        List<ArticleCategory> list = articleCategoryProvider.getlist();
        renderParamToBody("types", list, env, body);
    }
}
